#include <stdio.h>
#include <stdlib.h>
#include "hash.h"

static int TBL_SIZE = 5;
int main(int argc, char** argv) {
	PtrToTbl hashTbl = initHashTbl(TBL_SIZE);
	char* keys[] = {"foo1", "foo2", "foo3", "foo4", "foo5", "foo6", "foo7", "foo8", "foo8"};
	char* values[] = {"foo1", "foo2", "foo3", "foo4", "foo5", "foo6", "foo7", "foo8", "foo8"};
	int len = sizeof(keys) / sizeof(keys[0]);

	int i;
	for (i = 0; i < len; i++) {
		insert(hashTbl, keys[i], values[i]);
	}

	for (i = 0; i < len; i++) {
		getByKey(hashTbl, keys[i]);
	}
}

void getByKey(PtrToTbl tbl, KeyType key) {
	Position pos = find(tbl, key);
	if (pos != NULL)
		printf("key=%s, value=%s\n", key, retrieve(pos));
	else
		printf("key not found %s\n", key);
}